package cn.anjubao.cp.api.config.security;

import cn.anjubao.cp.api.common.ErrorNum;
import cn.anjubao.cp.common.base.BaseResponse;
import org.springframework.security.authentication.ProviderNotFoundException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class AuthenticationExHandler {

    @ExceptionHandler(ProviderNotFoundException.class)
    public BaseResponse<String> handleProviderNotFound(ProviderNotFoundException pe) {
        BaseResponse.BaseResponseBuilder<String> builder = BaseResponse.builder();
        return builder.result(ErrorNum.NOT_AUTHENTICATED.code)
                .message(ErrorNum.NOT_AUTHENTICATED.message)
                .build();
    }
}
